﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<FriendTest.Models.MyNews>>" %>
    <ul>
    <%foreach (var news in Model)
          {%>
          <li id="newslistitem" style="list-style-type: disc">
                <%="<img src=" +"../../Content/"+news.newsFrom.userName+".jpg align=\"left\"/>"
                 %>
                 <%if (news.newsPublishItem.itemType == 0)
                   { %>
                    <%Html.RenderAction("ShowStatusByItemId", new { itemId = news.newsPublishItem.itemId });%>
                    <%} %>
                 <%else
                   { %>
                    <%Html.RenderAction("ShowShareByItemId", new { itemId = news.newsPublishItem.itemId}); %>
                 <%} %>
           <div>
           <a id="<%="reply1"+news.newsId %>" style="display:inline" href="#nogo" onclick="document.getElementById('<%="comment_list"+news.newsId%>').setAttribute('style','display:block');
                                            document.getElementById('<%="reply"+news.newsId%>').setAttribute('style','display:inline');
                                            document.getElementById('<%="reply1"+news.newsId%>').setAttribute('style','display:none')">显示回复</a>           
           <a id="<%="reply"+news.newsId %>" style="display:none" href="#nogo" onclick="document.getElementById('<%="comment_list"+news.newsId%>').setAttribute('style','display:none');
                                            document.getElementById('<%="reply1"+news.newsId%>').setAttribute('style','display:inline');
                                            document.getElementById('<%="reply"+news.newsId%>').setAttribute('style','display:none')" >收起回复</a>
           <span>|</span>
           <%=Ajax.ActionLink("删除", "DeleteNews", new { newsId = news.newsId, user = news.userId}, new AjaxOptions{UpdateTargetId = "news_list"})%>
           </div>

            <div id="comment_list<%=news.newsId %>" style="display:none">
                <%Html.RenderAction("ShowCmtList", new { id = news.newsPublishItem.itemId});%>            
           </div>

            <% using (Ajax.BeginForm("AddComment",
                                    new { itemId = news.newsPublishItem.itemId, fromUser = news.userId, toUser = 1 },
                                    new AjaxOptions
                                    {
                                        UpdateTargetId = "comment_list" + news.newsId,
                                        InsertionMode = InsertionMode.Replace
                                    }
                                                     ))
               { %>
                <%=Html.TextBox("comment", "添加回复")%>
                <input type="submit" value="回复" /><br />
            <%} %>
            </li>
            <%} %>
    </ul>

